import 'package:flutter/material.dart';
import 'package:flutterappmydemo/utils/image_helper.dart';

class FlexibleSpaceBarDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return NestedScrollView(
      headerSliverBuilder: (BuildContext content, bool innerBoxIsScrolled) {
        return <Widget>[
          SliverAppBar(
            //展开高度
            expandedHeight: 200,
            automaticallyImplyLeading: true,

            //不随着滑动隐藏标题,测试发现不起作用
            floating: false,
            snap: false,
            //是否固定在顶部
            pinned: true,

            elevation: 0,

            centerTitle: true,
            title: Text("可折叠组件",
                style: TextStyle(color: Colors.white, fontSize: 16.0)),

            flexibleSpace: FlexibleSpaceBar(
              //  collapseMode: CollapseMode.parallax,
              stretchModes: const <StretchMode>[StretchMode.blurBackground],
              /* centerTitle: true,
              title: Text("可折叠组件",
                  style: TextStyle(color: Colors.white, fontSize: 16.0)),*/
              background: ImageHelper.loadAssetsImageJPEG("wudang"),
            ),
          ),
        ];
      },
      body: Container(
        color: Colors.white,
        child: Text(
          "内容内容内容内容内容内容内容内容内容1111",
          style: TextStyle(
            color: Colors.greenAccent,
            fontSize: 16.0,
            decoration: TextDecoration.none,
          ),
        ),
      ),
    );
  }
}
